#include "tlv_writer.h"

TLVWriter::TLVWriter(TLVBuffer& buffer) : buffer_(buffer) {}

bool TLVWriter::writeUint8(uint8_t value) {
    return buffer_.writeRaw(TLVType::UINT8, &value, sizeof(value));
}

bool TLVWriter::writeUint16(uint16_t value) {
    return buffer_.writeRaw(TLVType::UINT16, &value, sizeof(value));
}

bool TLVWriter::writeUint32(uint32_t value) {
    return buffer_.writeRaw(TLVType::UINT32, &value, sizeof(value));
}

bool TLVWriter::writeString(const std::string& str) {
    return buffer_.writeRaw(TLVType::STRING, str.data(), static_cast<uint16_t>(str.size()));
}

bool TLVWriter::writeBlob(const std::vector<uint8_t>& blob) {
    return buffer_.writeRaw(TLVType::BLOB, blob.data(), static_cast<uint16_t>(blob.size()));
}
